package wwj.bean;

import com.sun.org.apache.xpath.internal.operations.Bool;

import java.math.BigDecimal;

public class CartItem {
    private boolean checked;
    private CommodityBean commodity;
    private int num;
    private BigDecimal subTotal;
    private Boolean itemZero = false;

    public boolean isChecked() {
        return checked;
    }

    public Boolean getItemZero() {
        return itemZero;
    }

    public void setItemZero(Boolean itemZero) {
        this.itemZero = itemZero;
    }

    public CartItem(CommodityBean commodity) {
        this.checked = true;
        this.commodity = commodity;
        this.num = 1;
        setSubTotal(commodity.getPrice());
    }

    public boolean getChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    public CommodityBean getCommodity() {
        return commodity;
    }

    public void setCommodity(CommodityBean commodityBean) {
        this.commodity = commodityBean;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
        setSubTotal(commodity.getPrice().multiply(new BigDecimal(num)));
    }

    public BigDecimal getSubTotal() {
        return subTotal;
    }

    public void setSubTotal(BigDecimal subTotal) {
        this.subTotal = subTotal;
    }

    @Override
    public String toString() {
        return "CartItem{" +
                "checked=" + checked +
                ", commodity=" + commodity +
                ", num=" + num +
                ", subTotal=" + subTotal +
                '}';
    }
}
